//
//  SIXPPresentationController.m
//  weibo
//
//  Created by   李小云 on 16/5/20.
//  Copyright © 2016年 chuhan. All rights reserved.
//

#import "SIXPPresentationController.h"
#import "Masonry.h"

@interface SIXPPresentationController()
/** button */
@property(nonatomic , strong)UIButton * HUD;
@end

@implementation SIXPPresentationController

//这个类就是管理过度View的类 (containerView的Controller)

-(UIButton *)HUD
{
    if (!_HUD) {
        _HUD = [UIButton buttonWithType:UIButtonTypeCustom];
    }
    return _HUD;
}
-(void)containerViewWillLayoutSubviews
{
    //    self.presentedViewController;//拿到弹出的VC
    //    self.presentingViewController;//拿到modal之前的VC
   [self.presentedView mas_makeConstraints:^(MASConstraintMaker *make) {
       
       make.top.mas_equalTo(8);
       make.right.offset(0);
       make.width.mas_equalTo(150);
       make.height.mas_equalTo(100);
        
   }];
}
//即将调用转场modal之前调用
-(void)presentationTransitionWillBegin
{
    [super presentationTransitionWillBegin];
    //需要添加HUD(懒加载)
    self.HUD.frame = self.containerView.bounds;
    //    self.HUD.backgroundColor = [UIColor blueColor];
    [self.containerView addSubview:_HUD];
    [self.HUD addTarget:self action:@selector(clickHUD) forControlEvents:UIControlEventTouchUpInside];
}


#pragma mark - 点击HUD
//是为了告诉系统 我要把转场动画弹出去 弹出就会调用- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext
-(void)clickHUD
{
    [self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
}
@end
